<template>
  <div class="mui-numbox" data-numbox-min="1" :data-numbox-max="max">
    <button class="mui-btn mui-numbox-btn-minus" type="button">-</button>
    <input class="mui-numbox-input" type="number" value="1"
      ref="count" @change="getCount" />
    <button class="mui-btn mui-numbox-btn-plus" type="button">+</button>
  </div>
</template>

<script>
import mui from '../../lib/mui/js/mui.min.js'

export default {
  name: 'goodsinfo-numbox',
  props: [ 'max' ],
  watch: {
    'max'(newVal,oldVal) {
      mui('.mui-numbox').numbox().setOption('max', newVal)
    }
  },
  methods: {
    getCount() {
      let count = this.$refs.count.value
      this.$emit('handNum', count)
    }
  },
}
</script>

<style lang="less" scoped>

</style>
